<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: pico_i2c_slave</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__pico__i2c__slave.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">pico_i2c_slave<div class="ingroups"><a class="el" href="group__high__level.html">High Level APIs</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Functions providing an interrupt driven I2C slave interface.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga8d4821831a9a533b701eca1016021c33"><td class="memItemLeft" align="right" valign="top"><a id="ga8d4821831a9a533b701eca1016021c33" name="ga8d4821831a9a533b701eca1016021c33"></a>
typedef enum <a class="el" href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">i2c_slave_event_t</a>&#160;</td><td class="memItemRight" valign="bottom"><b>i2c_slave_event_t</b></td></tr>
<tr class="memdesc:ga8d4821831a9a533b701eca1016021c33"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C slave event types. <br /></td></tr>
<tr class="separator:ga8d4821831a9a533b701eca1016021c33"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf1bb7bb1e79c309b290bf0e8ccd57dff"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pico__i2c__slave.html#gaf1bb7bb1e79c309b290bf0e8ccd57dff">i2c_slave_handler_t</a>) (<a class="el" href="structi2c__inst.html">i2c_inst_t</a> *i2c, <a class="el" href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">i2c_slave_event_t</a> event)</td></tr>
<tr class="memdesc:gaf1bb7bb1e79c309b290bf0e8ccd57dff"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C slave event handler.  <a href="group__pico__i2c__slave.html#gaf1bb7bb1e79c309b290bf0e8ccd57dff">More...</a><br /></td></tr>
<tr class="separator:gaf1bb7bb1e79c309b290bf0e8ccd57dff"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gad8b613f0d4e9d1b9511ca0b6d6ab7e8c"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">i2c_slave_event_t</a> { <a class="el" href="group__pico__i2c__slave.html#ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca7bc1a9bb9db707479c140a49c4d62a51">I2C_SLAVE_RECEIVE</a>
, <a class="el" href="group__pico__i2c__slave.html#ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca495a6f0ce75738519ac201349ac38c22">I2C_SLAVE_REQUEST</a>
, <a class="el" href="group__pico__i2c__slave.html#ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca857dc8c139941a8f8bb6888a84e4b83f">I2C_SLAVE_FINISH</a>
 }</td></tr>
<tr class="memdesc:gad8b613f0d4e9d1b9511ca0b6d6ab7e8c"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C slave event types.  <a href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">More...</a><br /></td></tr>
<tr class="separator:gad8b613f0d4e9d1b9511ca0b6d6ab7e8c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga2ecc43ff4a3c673a704d0c7bd7d91db4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pico__i2c__slave.html#ga2ecc43ff4a3c673a704d0c7bd7d91db4">i2c_slave_init</a> (<a class="el" href="structi2c__inst.html">i2c_inst_t</a> *i2c, uint8_t address, <a class="el" href="group__pico__i2c__slave.html#gaf1bb7bb1e79c309b290bf0e8ccd57dff">i2c_slave_handler_t</a> handler)</td></tr>
<tr class="memdesc:ga2ecc43ff4a3c673a704d0c7bd7d91db4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure an I2C instance for slave mode.  <a href="group__pico__i2c__slave.html#ga2ecc43ff4a3c673a704d0c7bd7d91db4">More...</a><br /></td></tr>
<tr class="separator:ga2ecc43ff4a3c673a704d0c7bd7d91db4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaebbea8f5a707f23750ba3e0c8b5eb6ee"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pico__i2c__slave.html#gaebbea8f5a707f23750ba3e0c8b5eb6ee">i2c_slave_deinit</a> (<a class="el" href="structi2c__inst.html">i2c_inst_t</a> *i2c)</td></tr>
<tr class="memdesc:gaebbea8f5a707f23750ba3e0c8b5eb6ee"><td class="mdescLeft">&#160;</td><td class="mdescRight">Restore an I2C instance to master mode.  <a href="group__pico__i2c__slave.html#gaebbea8f5a707f23750ba3e0c8b5eb6ee">More...</a><br /></td></tr>
<tr class="separator:gaebbea8f5a707f23750ba3e0c8b5eb6ee"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Functions providing an interrupt driven I2C slave interface. </p>
<p >This I2C slave helper library configures slave mode and hooks the relevant I2C IRQ so that a user supplied handler is called with enumerated I2C events.</p>
<p >An example application <code>slave_mem_i2c</code>, which makes use of this library, can be found in <a href="https://github.com/raspberrypi/pico-examples/blob/master/i2c/slave_mem_i2c/slave_mem_i2c.c">pico_examples</a>. </p>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gaf1bb7bb1e79c309b290bf0e8ccd57dff" name="gaf1bb7bb1e79c309b290bf0e8ccd57dff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf1bb7bb1e79c309b290bf0e8ccd57dff">&#9670;&nbsp;</a></span>i2c_slave_handler_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* i2c_slave_handler_t) (<a class="el" href="structi2c__inst.html">i2c_inst_t</a> *i2c, <a class="el" href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">i2c_slave_event_t</a> event)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>I2C slave event handler. </p>
<p >The event handler will run from the I2C ISR, so it should return quickly (under 25 us at 400 kb/s). Avoid blocking inside the handler and split large data transfers across multiple calls for best results. When sending data to master, up to <a class="el" href="group__hardware__i2c.html#ga93f40022189e591521dd0ae5e29708ff">i2c_get_write_available()</a> bytes can be written without blocking. When receiving data from master, up to <a class="el" href="group__hardware__i2c.html#ga5df361f77f110bbc2b63baa999507bde">i2c_get_read_available()</a> bytes can be read without blocking.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">i2c</td><td>Either <a class="el" href="rp2__common_2hardware__i2c_2include_2hardware_2i2c_8h.html#a46204d38a512926541fd8bac2b62c720">i2c0</a> or <a class="el" href="rp2__common_2hardware__i2c_2include_2hardware_2i2c_8h.html#a87659b485d9e76dfc3bcef208ac4b573">i2c1</a> </td></tr>
    <tr><td class="paramname">event</td><td>Event type. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="gad8b613f0d4e9d1b9511ca0b6d6ab7e8c" name="gad8b613f0d4e9d1b9511ca0b6d6ab7e8c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">&#9670;&nbsp;</a></span>i2c_slave_event_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__pico__i2c__slave.html#gad8b613f0d4e9d1b9511ca0b6d6ab7e8c">i2c_slave_event_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>I2C slave event types. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca7bc1a9bb9db707479c140a49c4d62a51" name="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca7bc1a9bb9db707479c140a49c4d62a51"></a>I2C_SLAVE_RECEIVE&#160;</td><td class="fielddoc"><p >Data from master is available for reading. Slave must read from Rx FIFO. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca495a6f0ce75738519ac201349ac38c22" name="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca495a6f0ce75738519ac201349ac38c22"></a>I2C_SLAVE_REQUEST&#160;</td><td class="fielddoc"><p >Master is requesting data. Slave must write into Tx FIFO. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca857dc8c139941a8f8bb6888a84e4b83f" name="ggad8b613f0d4e9d1b9511ca0b6d6ab7e8ca857dc8c139941a8f8bb6888a84e4b83f"></a>I2C_SLAVE_FINISH&#160;</td><td class="fielddoc"><p >Master has sent a Stop or Restart signal. Slave may prepare for the next transfer. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaebbea8f5a707f23750ba3e0c8b5eb6ee" name="gaebbea8f5a707f23750ba3e0c8b5eb6ee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaebbea8f5a707f23750ba3e0c8b5eb6ee">&#9670;&nbsp;</a></span>i2c_slave_deinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void i2c_slave_deinit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structi2c__inst.html">i2c_inst_t</a> *&#160;</td>
          <td class="paramname"><em>i2c</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Restore an I2C instance to master mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">i2c</td><td>Either <a class="el" href="rp2__common_2hardware__i2c_2include_2hardware_2i2c_8h.html#a46204d38a512926541fd8bac2b62c720">i2c0</a> or <a class="el" href="rp2__common_2hardware__i2c_2include_2hardware_2i2c_8h.html#a87659b485d9e76dfc3bcef208ac4b573">i2c1</a> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga2ecc43ff4a3c673a704d0c7bd7d91db4" name="ga2ecc43ff4a3c673a704d0c7bd7d91db4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2ecc43ff4a3c673a704d0c7bd7d91db4">&#9670;&nbsp;</a></span>i2c_slave_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void i2c_slave_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structi2c__inst.html">i2c_inst_t</a> *&#160;</td>
          <td class="paramname"><em>i2c</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__pico__i2c__slave.html#gaf1bb7bb1e79c309b290bf0e8ccd57dff">i2c_slave_handler_t</a>&#160;</td>
          <td class="paramname"><em>handler</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Configure an I2C instance for slave mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">i2c</td><td>I2C instance. </td></tr>
    <tr><td class="paramname">address</td><td>7-bit slave address. </td></tr>
    <tr><td class="paramname">handler</td><td>Callback for events from I2C master. It will run from the I2C ISR, on the CPU core where the slave was initialised. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>